﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using iuPlace.Core.Models;
using iuPlace.Web.Extensions;

namespace iuPlace.Web.Controllers
{
    public class DefaultController : BaseController
    {
        public ActionResult Index()
        {
            //return this.Render(this.Request.Browser.IsMobileDevice ? TypeView.Mobile : TypeView.Site);
            return this.Render(TypeView.Mobile);
        }

        public ViewResult Site()
        {
            return this.Render(TypeView.Site);
        }

        public ViewResult Mobile()
        {
            return this.Render(TypeView.Mobile);
        }

        private ViewResult Render(TypeView view)
        {
            iuPlaceApplication.Current.CurrentSession.Container.Type = this.Request.UserAgent.Contains(iuPlace.Core.Settings.MobileApplication) ? TypeContainer.Application : TypeContainer.Browser;
            iuPlaceApplication.Current.CurrentSession.Container.View = (TypeView)view;
            var model = this.CreateViewModel();
            return View(string.Format("~/Areas/{0}/Views/Default/Main.cshtml", iuPlaceApplication.Current.CurrentSession.Container.View.ToString()), model);
        }
    }
}
